package Practice;

import java.util.Scanner;

public class Demo2Squence {
    public static void main(String[] args) {
        shunxu();
        System.out.println("=========================");
        if1();
        System.out.println("==========================");
        ifelse();
        System.out.println("=====================");
        ifelseifelse();
        System.out.println("======================");
        switch1();
        System.out.println("=========================");
        for1();
        System.out.println("=======================");
        while1();
        System.out.println("======================");
        dowhile();

    }
    public static void shunxu() {
        System.out.println("顺序结构");
        System.out.println("按顺序执行");
    }

    public static void if1() {
        System.out.println("这里是判断语句测试");
        System.out.println("今天去网吧");
        int age = 19;
        if (age > 18 && age < 60){
            System.out.println("进入网吧，愉快开黑");
        }
    }
    public static void ifelse() {
        int num = 13;
        if (num % 2 ==0){
            System.out.println("这是偶数");
        }
        else {
            System.out.println("这是奇数");
        }
    }

    public static void ifelseifelse() {
        int x = 10;
        int y;
        if (x>=3){
            y = x*2+1;
            System.out.println(y);
        } else if (-1<x && x<=2){
            y = x*10;
            System.out.println(y);
        }else {
            System.out.println(y=1);
        }
    }

    /*
    switch语句使用注意事项：
    1、多个case后面的数值不可以重复
    2、switch后面的小括号中只能是下列数据类型：
    基本数据类型：byte/short/char/int
    引用数据类型：String字符串、enum枚举
    3、switch 语句格式可以很灵活，前后顺序可以颠倒，而且break语句还可以省略
    ”匹配哪一个case 就从哪一个位置向下执行，直到遇到了break或整体结束为止“
     */
    public static void switch1() {
        int num = 1;
        switch (num){
            case 1:
                System.out.println("星期一");

            case 2:
                System.out.println("星期二");
                break;

            default:
                System.out.println("default");
                break;
            case 3:
                System.out.println("Xiqngiq");
                break;
        }
    }

    public static void for1() {
        int sum = 0;
        for (int i = 1;i<10;i++){
            sum+=i;
        }
        System.out.println(sum);
    }

    public static void while1() {
        for (int i = 1;i<=10;i++){
            System.out.println("我错" + i);
        }
        System.out.println("====================");
        int i=1;
        while (i<=10){
            System.out.println("我错"+i);
            i++;
        }

    }

    public static void dowhile() {
        for (int i=1;i<10;i++){
            System.out.println("起来吧"+i);
        }
        System.out.println("================================");
        int i=1;
        do {
            System.out.println("起来吧"+i);
            i++;
        } while (i<10);
    }


}
